package flc.ast.adapter;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.ConvertUtils;
import com.blankj.utilcode.util.FileUtils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.SelectFileBean;
import flc.ast.utils.MyUtils;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class AppRecordAdapter extends StkProviderMultiAdapter<SelectFileBean> {

    public AppRecordAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(82));
        addItemProvider(new AppRecordProvider());
    }

    private class AppRecordProvider extends BaseItemProvider<SelectFileBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_app_record;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, SelectFileBean bean) {
            baseViewHolder.setText(R.id.tvAppRecordItemName, bean.getName());
            baseViewHolder.setText(R.id.tvAppRecordItemSize, ConvertUtils.byte2FitMemorySize(bean.getSize(), 0));
            baseViewHolder.setImageDrawable(R.id.ivAppRecordItemImg, AppUtils.getAppIcon(bean.getPath()));
//            Glide.with(baseViewHolder.itemView).load(bean.getPath()).into((ImageView) baseViewHolder.getView(R.id.ivAppRecordItemImg));
            baseViewHolder.setImageDrawable(R.id.ivAppRecordItemImg, AppUtils.getAppIcon(bean.getPath()));

        }
    }


}
